package com.test.mytest.llk;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.custom.CLabel;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;

public class MainApp {

	protected Shell shell;
	
	String select=null;
	CLabel selectLabel=null;

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			MainApp window = new MainApp();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}
	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(450, 300);
		shell.setText("SWT Application");
		FillLayout fl_shell = new FillLayout(SWT.HORIZONTAL);
		fl_shell.marginWidth = 30;
		fl_shell.marginHeight = 30;
		shell.setLayout(fl_shell);
		
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setLayout(new GridLayout(3, false));
		
		CLabel lblNewLabel = new CLabel(composite, SWT.NONE);
		lblNewLabel.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				CLabel source = (CLabel) e.getSource();
				if (select==null&&selectLabel==null) {
					select=source.getText();
					selectLabel=source;
				}else{
					if (source.getText().equals(select)) {}
				}
			}
		});
		GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gd_lblNewLabel.heightHint = 30;
		gd_lblNewLabel.widthHint = 30;
		lblNewLabel.setLayoutData(gd_lblNewLabel);
		lblNewLabel.setText("A");
		
		CLabel lblNewLabel_1 = new CLabel(composite, SWT.NONE);
		lblNewLabel_1.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
			}
		});
		GridData gd_lblNewLabel_1 = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gd_lblNewLabel_1.widthHint = 30;
		gd_lblNewLabel_1.heightHint = 30;
		lblNewLabel_1.setLayoutData(gd_lblNewLabel_1);
		lblNewLabel_1.setText("B");
		
		CLabel lblA = new CLabel(composite, SWT.NONE);
		lblA.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
			}
		});
		GridData gd_lblA = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
		gd_lblA.heightHint = 30;
		gd_lblA.widthHint = 30;
		lblA.setLayoutData(gd_lblA);
		lblA.setText("A");

	}
}
